package com.ruoyi.project.module.interAcc.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.constant.BusinessType;
import com.ruoyi.project.module.interAcc.domain.InterAcc;
import com.ruoyi.project.module.interAcc.service.IInterAccService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.page.TableDataInfo;
import com.ruoyi.framework.web.domain.AjaxResult;

/**
 * Internet加速管理 信息操作处理
 * 
 * @author ruoyi
 * @date 2018-07-19
 */
@Controller
@RequestMapping("/module/interAcc")
public class InterAccController extends BaseController
{
    private String prefix = "module/interAcc";
	
	@Autowired
	private IInterAccService interAccService;
	
	@RequiresPermissions("module:interAcc:view")
	@GetMapping()
	public String interAcc()
	{
	    return prefix + "/interAcc";
	}
	
	/**
	 * 查询Internet加速管理列表
	 */
	@RequiresPermissions("module:interAcc:list")
	@PostMapping("/list")
	@ResponseBody
	public TableDataInfo list(InterAcc interAcc)
	{
		startPage();
        List<InterAcc> list = interAccService.selectInterAccList(interAcc);
		return getDataTable(list);
	}
	
	/**
	 * 新增Internet加速管理
	 */
	@RequiresPermissions("module:interAcc:add")
	@Log(title = "Internet加速管理", action = BusinessType.INSERT)
	@GetMapping("/add")
	public String add()
	{
	    return prefix + "/add";
	}

	/**
	 * 修改Internet加速管理
	 */
	@RequiresPermissions("module:interAcc:edit")
	@Log(title = "Internet加速管理", action = BusinessType.UPDATE)
	@GetMapping("/edit/{interId}")
	public String edit(@PathVariable("interId") Integer interId, Model model)
	{
		InterAcc interAcc = interAccService.selectInterAccById(interId);
		model.addAttribute("interAcc", interAcc);
	    return prefix + "/edit";
	}
	
	/**
	 * 保存Internet加速管理
	 */
	@RequiresPermissions("module:interAcc:save")
	@Log(title = "Internet加速管理", action = BusinessType.SAVE)
	@PostMapping("/save")
	@ResponseBody
	public AjaxResult save(InterAcc interAcc)
	{
		if (interAccService.saveInterAcc(interAcc) > 0)
		{
			return success();
		}
		return error();
	}
	
	/**
	 * 删除Internet加速管理
	 */
	@RequiresPermissions("module:interAcc:remove")
	@Log(title = "Internet加速管理", action = BusinessType.DELETE)
	@PostMapping( "/remove")
	@ResponseBody
	public AjaxResult remove(String ids)
	{
		int rows = interAccService.deleteInterAccByIds(ids);
		if (rows > 0)
        {
            return success();
        }
        return error();
	}
	
}
